#include <iostream>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int ans=a*60+b+c;
  int ans1=ans/60;
  int ans2=ans%60;
  cout<<ans1<<endl;
  cout<<ans2<<endl;
  return 0;
}
